package com.lft.com.oilgas.controller;


import com.lft.com.oilgas.entity.CommodityRole;
import com.lft.com.oilgas.service.ICommodityRoleService;
import com.lft.com.oilgas.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tyqw
 * @since 2024-09-10
 */
@RestController
@CrossOrigin
@RestControllerAdvice
@RequestMapping("/util/commodity-role")
public class CommodityRoleController {
    //处理异常
    @ExceptionHandler(Exception.class)
    private Result yichang(Exception e){
        //noinspection CallToPrintStackTrace
        e.printStackTrace();
        return new Result(false,"服务器异常，请稍后重试");
    }

    @Autowired
    private ICommodityRoleService iCommodityRoleService;

    //查询所有分类
    @RequestMapping("/all")
    public Result selectAll(){
        List<CommodityRole> commodityRoles = iCommodityRoleService.selectAll();
        return new Result(true,commodityRoles);
    }
}
